﻿using System;

namespace Behaving.Decorators
{
    public class Inverter : Decorator
    {
        public Inverter(Behaviour behaviour)
            : base(behaviour)
        {
        }

        public override RunningState Execute(BehaviourTree behaviourTree)
        {
            RunningState runningState = Behaviour.Execute(behaviourTree);

            switch (runningState)
            {
                case RunningState.Success:
                    return RunningState.Failure;
                case RunningState.Failure:
                    return RunningState.Success;
                case RunningState.Running:
                    return RunningState.Running;
                default:
                    throw new ArgumentOutOfRangeException();
            }
        }
    }
}